<?php include ("include/header.php"); 

require_once 'Mail.php';


?>
	<div id="principal"> 
    	  <?php include ("include/menuIzq.php"); ?>
<?php 
	
	
	if(isSet($_POST['correo'])){
	    $from = "<andres.lopez.89@gmail.com>";
        $to = "<".$_POST['correo'].">";
        $subject = "Hi!";
        $body = "Hi,\n\nHow are you?";

        $host = "ssl://smtp.gmail.com";
        $port = "465";
        $username = "<andres.lopez.89@gmail.com>";
        $password = "";

        $headers = array ('From' => $from,
          'To' => $to,
          'Subject' => $subject);
        $smtp = Mail::factory('smtp',
          array ('host' => $host,
            'port' => $port,
            'auth' => true,
            'username' => $username,
            'password' => $password));

        $mail = $smtp->send($to, $headers, $body);

        if (PEAR::isError($mail)) {
          echo("<p>" . $mail->getMessage() . "</p>");
         } else {
          echo("<p>Message successfully sent!</p>");
         }
	}
	else{
		echo"
			  <p>Ingresa tu correo electr&oacute;nico registrado con nosotros para que podamos enviarte una nueva contrase&ntilde;a.</p><br/>
			  <form id=\"form_restablecer\" action=\"/SubWebPHP/web/restablecercontrasena.php\" method=\"post\">
				<table width=\"590\" border=\"0\">
				  <tr>
				  <span id=\"validacion_text_email\">
					<td width=\"160\">
					  <label for=\"correo\">Correo</label>
					</td>
					<td width=\"430\">
					  <input type=\"text\" name=\"correo\" id=\"correo\" />
					  <span class=\"textfieldRequiredMsg\">Debes ingresar tu correo electr&oacute;nico.</span> 
					  <span class=\"textfieldMaxCharsMsg\">Haz excedido el m&aacute;ximo n&uacute;mero de caracteres (40).</span>
					</td>
				  </span>
				  </tr>
				</table> 
			  <br/>
			  <input value=\"Recuperar contrase&ntilde;a\" type=\"submit\"/>
			</form>";
		  }
		?>
      </div>
      <div class="espacio"></div>
    </div>      
      
	<script type="text/javascript">
      var validacion_text_email = new Spry.Widget.ValidationTextField("validacion_text_email", "email", {validateOn:["change"], maxChars:40});
    </script>
    
<?php include("include/footer.php"); ?>